"""查询"""
import pymysql

db = None
try:
    db = pymysql.connect(
        host='localhost',
        port=3307,
        user='root',
        password='123456',
        database='myschools',
        charset='utf8'
    )
    # 建立游标
    cursor = db.cursor()
    cursor.execute("select * from students")
    print(cursor.fetchall())
    print(cursor.fetchone())

except Exception as e:
    print("异常", e)
finally:
    if db:
        db.close()
